<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script type="text/javascript">
    //根据url获取参数的hash表
    var getUrl = function(url) {
        //var url = window.location.href; // 获取当前url
        var paraString = url.substring(url.indexOf( "?") + 1, url.length).split("&" );
        //参数组
        var paraObj = {} 
        for (i = 0; j = paraString[i]; i++) {
          var index = j.indexOf("=");
           paraObj[j.substring(0, index).toLowerCase()] = j.substring(index + 1, j.length);
        }
        return paraObj;
    };
    //获取url中某参数的值
    var getParam = function(params,param){
            var returnValue = params[param.toLowerCase()];
            if (typeof (returnValue) == "undefined") {
               return "" ;                     //不存在，返回""
           } else {
               return returnValue;  //存在，返回
           }
    }

    function show() {
      var url = document.getElementById("data").value;
      alert(url);
      var params = getUrl(url);
      for (var strObjIndex in params) {
        alert( "strObjIndex = " + strObjIndex + "\nobject[" + strObjIndex + "] = "+ params[strObjIndex]); 
      }    

      //var url = http:\\www.cnblogs.com/qiongmiaoer/p/3559085.html?type=add&id=1;
      //var type = getParam(params,"type");
      //var id = getParam(params,"id");
    }
    
  </script>
</head>
<body>
  <input id="data" type="text" />
  <input type="button" onclick="show();" value="parse"/>
</body>
</html>